package com.example.C317DataSource.service.impl;

import com.example.C317DataSource.dao.MongoTestDao;
import com.example.C317DataSource.model.MongoTest;
import com.example.C317DataSource.service.IMongoTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * ImplMongoTestService
 *
 * @author wnm
 * @date 2020/12/29
 */
@Service
public class ImplMongoTestService implements IMongoTestService {

    @Autowired
    private MongoTestDao mtdao;

    @Override
    public void saveTest() {
        MongoTest mgtest=new MongoTest();
        mgtest.setId(11);
        mgtest.setAge(33);
        mgtest.setName("ceshi");
        mtdao.saveTest(mgtest);
    }

    @Override
    public MongoTest findTestByName(){
        MongoTest mgtest= mtdao.findTestByName("ceshi");
        System.out.println("mgtest is "+mgtest);
        return mgtest;
    }

    @Override
    public void updateTest(){
        MongoTest mgtest=new MongoTest();
        mgtest.setId(11);
        mgtest.setAge(44);
        mgtest.setName("ceshi");
        mtdao.updateTest(mgtest);
    }

    @Override
    public void deleteTestById(){
        mtdao.deleteTestById(11);
    }
}
